﻿// Copyright 2010 Maxime Serrano <lastchronicler@gmail.com>
using System;
using System.IO;
using System.Text;

namespace MCSharp.Network.Handlers
{
    public class ChatHandler : PacketHandler
    {
        #region PacketHandler Members
        public void Handle(BinaryReader reader, Session session, Player player)
        {
            player.ResetIdleTimer();
            string message = PacketReader.ReadString(reader);
            if (Player.CheckForIllegalChars(message))
            {
                Logger.Log("Player.ParseMessage: {0} attempted to write illegal characters in chat and was kicked.",
                            LogType.SuspiciousActivity,
                            player.GetLogName());
                session.KickNow("Illegal characters in chat.");
                return;
            }
            else
                player.ParseMessage(message, false);
        }
        #endregion
    }
}
